package guinew.view;

import info.clearthought.layout.TableLayout;

import java.util.ArrayList;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;

import javax.swing.tree.DefaultMutableTreeNode;

import core.Adapter;





/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
@SuppressWarnings("serial")
public class DetailView extends javax.swing.JFrame implements Runnable{
	private DefaultMutableTreeNode node;
	private JCheckBox jcbCanHaveChildren;
	private JCheckBox jcbIsAttributeValue;
	private JLabel jlblIsAttributeValue;
	private JCheckBox jcbIsAttributeKey;
	private JTextField jtfHashValue;
	private JLabel jlblHashValue;
	private JLabel jlblIsAttributeName;
	private JCheckBox jcbHasAttributes;
	private JLabel jlblHasAttributes;
	private JLabel jlblCanHaveChildren;
	private JTextField jtfName;
	private JLabel jlblName;
	private JPanel infoPanel;
	private JLabel jlblSaltValue;
	private JTextField jtfSaltValue;
	private ArrayList<String> nodeInfo = new ArrayList<String>();
	
	public DetailView(DefaultMutableTreeNode node) {
		super();
		this.node = node;
	}
	
	private void initGUI() {	
		nodeInfo = Adapter.getNodeInfo(node);
	
		pack();
		this.setSize(333, 261);
		this.setLocationRelativeTo(null);
		this.setVisible(true);    
		this.setTitle("Node Info");
		getContentPane().setLayout(null);
		
		infoPanel = new JPanel();
		TableLayout infoPanelLayout = new TableLayout(new double[][] {{107.0, 188.0}, {25.0, 25.0, 25.0, 25.0, 25.0, 25.0, 25.0}});
		infoPanelLayout.setHGap(5);
		infoPanelLayout.setVGap(5);
		infoPanel.setLayout(infoPanelLayout);
		getContentPane().add(infoPanel);
		infoPanel.setBounds(12, 12, 301, 211);

		jlblName = new JLabel();
		infoPanel.add(jlblName, "0, 0");
		jlblName.setText("Name:");

		jtfName = new JTextField();
		infoPanel.add(jtfName, "1, 0");
		jtfName.setText(nodeInfo.get(0));
		jtfName.setEditable(false);

		jlblCanHaveChildren = new JLabel();
		infoPanel.add(jlblCanHaveChildren, "0, 1");
		jlblCanHaveChildren.setText("Can have children:");

		jcbCanHaveChildren = new JCheckBox();
		infoPanel.add(jcbCanHaveChildren, "1, 1");
		jcbCanHaveChildren.setHorizontalAlignment(SwingConstants.CENTER);
		jcbCanHaveChildren.setSelected(Boolean.parseBoolean(nodeInfo.get(1)));
		jcbCanHaveChildren.setEnabled(false);

		jlblHasAttributes = new JLabel();
		infoPanel.add(jlblHasAttributes, "0, 2");
		jlblHasAttributes.setText("Has attributes:");

		jcbHasAttributes = new JCheckBox();
		infoPanel.add(jcbHasAttributes, "1, 2");
		jcbHasAttributes.setHorizontalAlignment(SwingConstants.CENTER);
		jcbHasAttributes.setSelected(Boolean.parseBoolean(nodeInfo.get(2)));
		jcbHasAttributes.setEnabled(false);

		jlblIsAttributeName = new JLabel();
		infoPanel.add(jlblIsAttributeName, "0, 3");
		jlblIsAttributeName.setText("Is attribute key:");

		jcbIsAttributeKey = new JCheckBox();
		infoPanel.add(jcbIsAttributeKey, "1, 3");
		jcbIsAttributeKey.setHorizontalAlignment(SwingConstants.CENTER);
		jcbIsAttributeKey.setSelected(Boolean.parseBoolean(nodeInfo.get(3)));
		jcbIsAttributeKey.setEnabled(false);
		
		jlblIsAttributeValue = new JLabel();
		infoPanel.add(jlblIsAttributeValue, "0, 4");
		jlblIsAttributeValue.setText("Is attribute value:");

		jcbIsAttributeValue = new JCheckBox();
		infoPanel.add(jcbIsAttributeValue, "1, 4");
		jcbIsAttributeValue.setHorizontalAlignment(SwingConstants.CENTER);
		jcbIsAttributeValue.setSelected(Boolean.parseBoolean(nodeInfo.get(4)));
		jcbIsAttributeValue.setEnabled(false);
		
		jlblHashValue = new JLabel();
		infoPanel.add(jlblHashValue, "0, 5");
		jlblHashValue.setText("Hash value:");

		jtfHashValue = new JTextField();
		infoPanel.add(jtfHashValue, "1, 5");
		jtfHashValue.setText(nodeInfo.get(5));
		jtfHashValue.setEditable(false);
		
		jlblSaltValue = new JLabel();
		infoPanel.add(jlblSaltValue, "0, 6");
		jlblSaltValue.setText("Salt - Value:");
		
		jtfSaltValue = new JTextField();
		infoPanel.add(jtfSaltValue, "1, 6");
		jtfSaltValue.setText(nodeInfo.get(6));
		jtfSaltValue.setEditable(false);
	}

	public void run() {
		initGUI();	
	}

}
